package com.ai.daofa;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;

/**
 * @author changchun.liang
 * @date 2024/4/19
 */
public class TestUUid {

    public static void main(String[] args) {

        //String simpleUUID = IdUtil.simpleUUID();
        //System.out.println("simpleUUID ---------> " + simpleUUID);
        //String fastSimpleUUID = IdUtil.fastSimpleUUID();
        //System.out.println("fastSimpleUUID -----> " + fastSimpleUUID);
        //String fastUUID = IdUtil.fastUUID();
        //System.out.println("fastUUID -----------> " + fastUUID);
        //String objectId = IdUtil.objectId();
        //System.out.println("objectId -----------> " + objectId);
        //String randomUUID = IdUtil.randomUUID();
        //System.out.println("randomUUID ---------> " + randomUUID);
        Snowflake snowflake = IdUtil.getSnowflake(1, 1);
        String nextIdStr = snowflake.nextIdStr();
        long nextId = snowflake.nextId();
        System.out.println("nextIdStr ----------> " + nextIdStr);
        System.out.println("nextId -------------> " + nextId);
        Snowflake snowflake1 = IdUtil.getSnowflake(2, 2);
        String nextIdStr1 = snowflake1.nextIdStr();
        long nextId1 = snowflake1.nextId();
        System.out.println("nextIdStr1 ---------> " + nextIdStr1);
        System.out.println("nextId1 ------------> " + nextId1);


        for(int i=0;i<60;i++) {
            nextId();
        }

    }

    public static long nextId(){
        int rd = RandomUtil.randomInt(1,31);
        System.out.println("randomInt ----------> " + rd);
        Snowflake snowflakei = cn.hutool.core.util.IdUtil.getSnowflake(rd, rd);
        long nextIdi = snowflakei.nextId();
        System.out.println("for nextIdi ------------> " + nextIdi);
        return nextIdi;
    }
}
